home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / oath.lha / oath / src / exportP.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-29  |  2.8 KB  |  100 lines

  1. //***************************************************************************
  2. //             OATH :: Object-oriented Abstract Type Hierarchy
  3. //***************************************************************************
  4. //
  5. //  Copyright (C) 1991, 1990  Texas Instruments Incorporated
  6. //  Permission is granted to any individual or institution
  7. //  to use, copy, modify, and distribute this software,
  8. //  provided that this complete copyright and permission notice
  9. //  is maintained, intact, in all copies and supporting documentation.
  10. //
  11. //  Texas Instruments Incorporated provides this software "as is"
  12. //  without express or implied warranty.
  13. //
  14. //***************************************************************************
  15. //  OATH obj export (exportP, importP, objRegisterP, oidP)
  16. //
  17. //  History:
  18. //    07/91  Brian M Kennedy  Original
  19. //
  20. //***************************************************************************
  21.  
  22. #include "copyright.h"
  23.  
  24. #include <oath/exportP.h>
  25.  
  26. #include <iostream.h>
  27.  
  28. #define OATH_EXPORT_FLAGS (ios::hex)
  29.  
  30. /////////////////////////////////////////////////////////////////////////////
  31. // exportP Outlines
  32.  
  33.     exportP::
  34. exportP ()
  35.    :LastOID(0), HashMask(0), Table(0), Stream(cout), StreamFlags(0)
  36.    {ensure(0, "This shouldn't be called!");}
  37.  
  38.     exportP::
  39. exportP (const exportP&)
  40.    :LastOID(0), HashMask(0), Table(0), Stream(cout), StreamFlags(0)
  41.    {ensure(0, "This shouldn't be called!");}
  42.  
  43.     exportP::
  44. exportP (ostream& S, unsigned int HashKey)
  45.    :LastOID(0), HashMask((1UL << HashKey) - 1),
  46.     Table(new objRegisterP* [HashMask + 1]),
  47.     Stream(S), StreamFlags(Stream.flags(OATH_EXPORT_FLAGS))
  48.    {Stream.width(0);
  49.     for(unsigned int I = 0; I <= HashMask; ++I)
  50.         Table[I] = 0;
  51.    }
  52.  
  53.     exportP::
  54. ~exportP ()
  55.    {Stream.flags(StreamFlags);}
  56.  
  57.     int exportP::
  58. registerObj (const oathCoreG* O, oidP& I)
  59.    {unsigned long Hash = HashMask & ((unsigned long)O >> 3);
  60.     I = (Table[Hash] ? Table[Hash]->oid(O) : oidP(0));
  61.     if(I)
  62.     return 1;
  63.     else
  64.        {I = ++LastOID;
  65.     Table[Hash] = new objRegisterP (O, I, Table[Hash]);
  66.     return 0;
  67.        }
  68.    }
  69.  
  70.  
  71. /////////////////////////////////////////////////////////////////////////////
  72. // importP Outlines
  73.  
  74.     importP::
  75. importP ()
  76.    :HashMask(0), Table(0), Stream(cin), StreamFlags(0)
  77.    {ensure(0, "This shouldn't be called!");}
  78.  
  79.     importP::
  80. importP (const importP&)
  81.    :HashMask(0), Table(0), Stream(cin), StreamFlags(0)
  82.    {ensure(0, "This shouldn't be called!");}
  83.  
  84.     importP::
  85. importP (istream& S, unsigned int HashKey)
  86.    :HashMask((1UL << HashKey) - 1),
  87.     Table(new objRegisterP* [HashMask + 1]),
  88.     Stream(S), StreamFlags(Stream.flags(OATH_EXPORT_FLAGS))
  89.    {Stream.width(0);
  90.     for(unsigned int I = 0; I <= HashMask; ++I)
  91.         Table[I] = 0;
  92.    }
  93.  
  94.     importP::
  95. ~importP ()
  96.    {Stream.flags(StreamFlags);}
  97.  
  98.  
  99. //***************************************************************************
  100.